// 业务模块的api
import axios from '@/utils/request'

// 文档管理-查询左侧分类树结构
export function getDocTree(data) {
  return axios({
    method: 'get',
    url: '/editor/documentInfoClassify/tree',
    params: data
  })
}

// 文档管理-删除分类节点
export function deleteDocTreeNode(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentInfoClassify/' + id,
    data: {}
  })
}
// 文档管理-管理分类节点
export function handleDocTreeNode(data, method = 'post') {
  return axios({
    method,
    url: '/editor/documentInfoClassify',
    data
  })
}

// 查询文档列表
export function getDocList(params) {
  return axios({
    method: 'get',
    url: '/editor/documentInfo/page',
    params
  })
}

// 文档管理-新增文档
export function addDocInfo(data) {
  return axios({
    method: 'post',
    url: '/editor/documentInfo',
    data
  })
}
// 文档管理-编辑文档
export function editDocInfo(data) {
  return axios({
    method: 'post',
    url: '/editor/documentInfo/editInfo',
    data
  })
}
// 文档管理-文档详情
export function getDocInfo(data) {
  return axios({
    method: 'post',
    url: '/editor/documentInfo/baseInfo',
    data
  })
}
// 文档管理-发起文档审核
export function postAudit(data) {
  return axios({
    method: 'post',
    url: '/editor/documentAuditInfo/add',
    data
  })
}
// 文档管理-文档发布
export function publishDoc(data) {
  return axios({
    method: 'post',
    url: '/editor/documentInfo/publish',
    data
  })
}
// 文档管理-文档删除
export function deleteDoc(docNo) {
  return axios({
    method: 'delete',
    url: '/editor/documentInfo/' + docNo
  })
}
// 文档管理-文档升版
export function upgradeDoc(data) {
  return axios({
    method: 'post',
    url: '/editor/documentInfo/upgrade',
    data
  })
}

// 模板管理-查询左侧分类树结构
export function getTemplateAll() {
  return axios({
    method: 'get',
    url: '/editor/documentTemplateInfo/all'
  })
}
// 模板管理-查询左侧分类树结构
export function getTemplateTree(data) {
  return axios({
    method: 'get',
    url: '/editor/documentTemplateClassify/tree',
    params: data
  })
}
// 模板管理-管理分类节点
export function handleTemplateTreeNode(data, method = 'post') {
  return axios({
    method,
    url: '/editor/documentTemplateClassify',
    data
  })
}

// 模板管理-删除分类节点
export function deleteTemplateTreeNode(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentTemplateClassify/' + id,
    data: {}
  })
}
// 管理文档模板
export function handleTemplateInfo(data, method = 'post') {
  return axios({
    method,
    url: '/editor/documentTemplateInfo',
    data
  })
}
export function getMajorList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentTemplateInfo/major/list',
    params: data
  })
}
export function getTemplateInfo(id) {
  return axios({
    method: 'get',
    url: '/editor/documentTemplateInfo/' + id,
    params: {}
  })
}
// 发布模板
export function publishTemplate(data) {
  return axios({
    method: 'put',
    url: '/editor/documentTemplateInfo/change',
    data
  })
}

// 模板管理-删除分类节点
export function deleteBlockTreeNode(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentBlockClassify/' + id,
    data: {}
  })
}
export function deleteTemplateInfo(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentTemplateInfo/' + id,
    data: {}
  })
}
// 新增模板-查询规范类型
export function getRulesList(params) {
  return axios({
    method: 'get',
    url: '/editor/standardRuleInfo/treeSelect',
    params
  })
}
// 查询文档模板列表
export function getTemplateList(params) {
  return axios({
    method: 'get',
    url: '/editor/documentTemplateInfo/page',
    params
  })
}

// 结构化内容块管理-查询左侧分类树结构
export function getBlockTree(data) {
  return axios({
    method: 'get',
    url: '/editor/documentBlockClassify/tree',
    params: data
  })
}
// 管理结构化内容块
export function handleBlockTreeNode(data, method = 'post') {
  return axios({
    method,
    url: '/editor/documentBlockClassify',
    data
  })
}
// 查询结构化块内容列表
export function getBlocksList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentBlockInfo/page',
    params: data
  })
}
export function getBlockInfo(id) {
  return axios({
    method: 'get',
    url: '/editor/documentBlockInfo/' + id,
    params: {}
  })
}
export function deleteBlockInfo(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentBlockInfo/' + id,
    data: {}
  })
}
export function handleBlockInfo(data) {
  return axios({
    method: 'put',
    url: '/editor/documentBlockInfo',
    data
  })
}
// 修改结构化内容块的状态
export function handleBlockStatus(data) {
  return axios({
    method: 'put',
    url: '/editor/documentBlockInfo/change',
    data
  })
}
export function addBlockInfo(data) {
  return axios({
    method: 'post',
    url: '/editor/documentBlockInfo',
    data
  })
}
// 获取规范要求配置表
export function getStandardRulesList(data) {
  return axios({
    method: 'get',
    url: '/editor/standardRuleInfo/list',
    params: data
  })
}
export function handleRuleInfo(data, method = 'post') {
  return axios({
    method,
    url: '/editor/standardRuleInfo',
    data
  })
}
export function changeRuleStatus(data) {
  return axios({
    method: 'put',
    url: '/editor/standardRuleInfo/change',
    data
  })
}
export function getRuleStructureList(data) {
  return axios({
    method: 'get',
    url: '/editor/standardRuleStructure/list',
    params: data
  })
}
// 查询表达式
export function getExpressionList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentExpressionInfo/page',
    params: data
  })
}
// 查询字体字号
export function getFontStyleList(data) {
  return axios({
    method: 'get',
    url: '/editor/standardRuleFont/list',
    params: data
  })
}
export function updateRuleStructure(data) {
  return axios({
    method: 'put',
    url: '/editor/standardRuleStructure',
    data
  })
}
export function updateRuleFonts(data) {
  return axios({
    method: 'put',
    url: '/editor/standardRuleFont',
    data
  })
}
// 查询系统术语
export function getSysTermsList(data) {
  return axios({
    method: 'get',
    url: '/editor/termsInfo/system/page',
    params: data
  })
}
// 查询术语
export function getTermsList(data) {
  return axios({
    method: 'get',
    url: '/editor/termsInfo/page',
    params: data
  })
}
export function getSysAbbreviationList(data) {
  return axios({
    method: 'get',
    url: '/editor/abbreviationInfo/system/page',
    params: data
  })
}
export function getAbbreviationList(data) {
  return axios({
    method: 'get',
    url: '/editor/abbreviationInfo/page',
    params: data
  })
}
// 查询个人术语
export function getMyTermList(data) {
  return axios({
    method: 'get',
    url: '/editor/termsInfo/self/page',
    params: data
  })
}
export function getMyAbbreviationList(data) {
  return axios({
    method: 'get',
    url: '/editor/abbreviationInfo/self/page',
    params: data
  })
}
// 删除个人术语
export function deleteMyTerm(id) {
  return axios({
    method: 'delete',
    url: `/editor/termsInfo/${id}`
  })
}
export function deleteMyAbbreviation(id) {
  return axios({
    method: 'delete',
    url: `/editor/abbreviationInfo/${id}`
  })
}
// 查询标准列表
export function getStandardList(data) {
  return axios({
    method: 'get',
    url: '/editor/depend/standard/page',
    params: data
  })
}
export function publishTerms(data, method = 'post') {
  return axios({
    method,
    url: '/editor/termsInfo/publish',
    data
  })
}
export function updateTermInfo(data) {
  return axios({
    method: 'PUT',
    url: '/editor/termsInfo',
    data
  })
}

export function handleAbbreviation(data, method = 'post') {
  return axios({
    method,
    url: '/editor/abbreviationInfo',
    data
  })
}
export function handleTerm(data, method = 'post') {
  return axios({
    method,
    url: '/editor/termsInfo',
    data
  })
}
// 切换术语状态
export function switchTermStatus(data) {
  return axios({
    method: 'put',
    url: '/editor/termsInfo/change',
    data
  })
}
// 切换缩略语状态
export function switchAbbreviationStatus(data) {
  return axios({
    method: 'put',
    url: '/editor/abbreviationInfo/change',
    data
  })
}
// 查询个人收藏分类列表
export function getFavouriteClassifyList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentCollectClassify/list',
    params: data
  })
}
// 查询个人收藏列表
export function getFavouriteList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentCollectInfo/page',
    params: data
  })
}
export function deleteFavouriteItem(id) {
  return axios({
    method: 'delete',
    url: '/editor/documentCollectInfo/' + id,
    data: {}
  })
}
// 修改个人收藏的基本信息
export function updateFavouriteItem(data) {
  return axios({
    method: 'put',
    url: '/editor/documentCollectInfo',
    data
  })
}
// 读取菜单
export function getStpMenus() {
  return axios({
    url: window.location.origin + '/document/management/menu/getRouters',
    method: 'get'
  })
}
// 读取当前登录账户
export function getCurrentUserInfo() {
  return axios({
    url: '/editor/depend/currentUser',
    method: 'get'
  })
}

// 关联解析结果到生产环境
export function getLinkProduction(data) {
  return axios({
    url: '/editor/documentInfo/json/sync',
    method: 'post',
    data
  })
}

// 查询文档协作分页
export function getCooperateList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentCooperateInfo/page',
    params: data
  })
}
// 查询文档协作分页
export function getAuditList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentAuditInfo/page',
    params: data
  })
}
// 查询文档引用记录分页
export function getReferenceRecordList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentReferenceRecord/page',
    params: data
  })
}
// 查询文档任务消息分页
export function getUnreadList(data) {
  return axios({
    method: 'get',
    url: '/editor/documentTaskMsg/page',
    params: data
  })
}
// 消息已读
export function setRead(id) {
  return axios({
    method: 'post',
    url: '/editor/documentTaskMsg/read/' + id
  })
}
// 消息已读
export function setAllRead() {
  return axios({
    method: 'post',
    url: '/editor/documentTaskMsg/readAll'
  })
}
// 通过文档编号查询文档发布记录列表
export function getPublishRecordList(docNo) {
  return axios({
    method: 'get',
    url: '/editor/documentPublishRecord/list/' + docNo
  })
}
// 根据模板id查询历史模板列表
export function getTemplateVersionList(id) {
  return axios({
    method: 'get',
    url: `/editor/documentTemplateInfo/${id}/history`
  })
}
// 模板升版
export function upgradeTemplate(data) {
  return axios({
    method: 'post',
    url: `/editor/documentTemplateInfo/upgrade`,
    data
  })
}
// 模板升版
export function getDocClassifyTypeList() {
  return axios({
    method: 'get',
    url: `/editor/documentInfoClassify/type/list`
  })
}
// 按文档查询审核列表
export function getAuditInfoList(data) {
  return axios({
    method: 'post',
    url: `/editor/documentAuditInfo/list`,
    data
  })
}
// 提交审核
export function submitAudit(data) {
  return axios({
    method: 'post',
    url: `/editor/documentAuditInfo/finish`,
    data
  })
}
// 配置业务属性
export function addRoleBiz(data) {
  return axios({
    method: 'put',
    url: `/system/role/biz/add`,
    data
  })
}
// 获取业务属性
export function getRoleBiz(roleId) {
  return axios({
    method: 'get',
    url: `/system/role/biz/query?roleId=${roleId}`
  })
}
